package com.hansming.bss.modules.sfc.wxpay;

import java.util.Map;

import org.apache.commons.codec.digest.DigestUtils;

public class test {
	public static void main(String args[]) throws Exception{
		String resxml="<xml><appid><![CDATA[wxbe33a4bd413df686]]></appid><bank_type><![CDATA[CFT]]></bank_type><cash_fee><![CDATA[1]]></cash_fee><fee_type><![CDATA[CNY]]></fee_type><is_subscribe><![CDATA[N]]></is_subscribe><mch_id><![CDATA[1283598701]]></mch_id><nonce_str><![CDATA[6e666e20ce7b4782b4c7e00f11320c21]]></nonce_str><openid><![CDATA[odV0i0d2_hlXKUDxRwgE14loaq5o]]></openid><out_trade_no><![CDATA[161161125478953]]></out_trade_no><result_code><![CDATA[SUCCESS]]></result_code><return_code><![CDATA[SUCCESS]]></return_code><sign><![CDATA[697374EE9DD91F40736B8EE6FFF75A28]]></sign><time_end><![CDATA[20171227114436]]></time_end><total_fee>1</total_fee><trade_type><![CDATA[JSAPI]]></trade_type><transaction_id><![CDATA[4200000031201712272223002457]]></transaction_id></xml>";
		Map map = PayUtils.doXMLParse(resxml);
		
		
		
		map.remove("sign");
		String prestr=PayUtils.createLinkString(map);
		String mysign2 = PayUtils.sign(prestr, WxPayConfig.key, "utf-8").toUpperCase();
		
		
		
		
		
		
		String returnCode = (String) map.get("return_code"); 
		
		
		
		
		
		String mysign = DigestUtils.md5Hex( PayUtils.getContentBytes(PayUtils.createLinkString(map), "utf-8" ));    
		System.out.println("sign---->"+(String)map.get("sign"));
		System.out.println("mysign2----->"+mysign2);
		System.out.println("mysign---->"+mysign);
		System.out.println("returnCode"+returnCode);
		System.out.println("结果"+PayUtils.verify(PayUtils.createLinkString(map), (String)map.get("sign"), WxPayConfig.key, "utf-8"));
		if("SUCCESS".equals(returnCode)){ 
			if(PayUtils.verify(PayUtils.createLinkString(map), (String)map.get("sign"), WxPayConfig.key, "utf-8")){
				System.out.println("123456");
			}else{
				System.out.println("78910jqk");
			}	
		}
	}
}
